02_COMPUTER_SCIENCE_NOTES (HTML, CSS, JS)
Week 8 DOM Architecture · Dual Sovereign Core (AR / EN)
⚡ DOM TREE GRAPH ARCHITECTURE & JAVASCRIPT EVENT LOOPS
AYMAN ELMASRY
Computational Creative Director · AI Prompt Engineer
Founder of Ayman Elmasry LLC
🔒 ⚡ AEL Sovereign Seal (Active Master Verification)
{
  "ael_seal": "AEL CS Encyclopedia — © Ayman Elmasry",
  "owner": "Ayman Elmasry",
  "legal_entities": [
    "Ayman Elmasry LLC (UAE)",
    "Ayman Elmasry Advertising & Marketing (Egypt)"
  ],
  "syllabus_source": "Harvard CS50x 2026-2027",
  "domain": "Week 8 (HTML, CSS, JavaScript): DOM Architecture, Event Loops & UI Glassmorphism",
  "document_type": "02_Computer_Science_Notes",
  "methodology": "8-Stage Sub-Silicon Execution Paradigm",
  "system_version": "v3.0"
}

Computer Science Notes: Tree Graphs & The Asynchronous Event Loop

Document Object Model (DOM) Tree Hierarchy

The browser engine parses raw HTML tags and constructs a structural tree graph of Nodes. The root object is document, branching down to html, head, and body. Every single node within the DOM tree is instantiated in memory as a live, dynamic object containing mutable properties and callable methods accessible directly via runtime scripting.

===================================================================================
                   DOCUMENT OBJECT MODEL (DOM) TREE HIERARCHY
===================================================================================

                        [ document ]
                             │
                         [ html ]
                        /        \
                    [ head ]    [ body ]
                                 /    \
                           [ div ]    [ section ]
                            /   \          │
                       [ h1 ]  [ p ]    [ button ]

===================================================================================

The Asynchronous Event Loop

JavaScript operates natively as a single-threaded runtime environment but achieves non-blocking, highly concurrent behavior through a dedicated orchestration system:

  • Call Stack: Operates on a Last-In, First-Out (LIFO) basis, executing active synchronous function frames.
  • Web APIs: Browser-managed background threads handling timers (setTimeout), network sockets (fetch), and event listeners.
  • Task Queue: Operates on a First-In, First-Out (FIFO) basis, queuing completed callback functions ready for execution.
  • Event Loop: The perpetual sentinel that monitors the Call Stack; the moment the stack clears, it instantly pushes the next callback from the Task Queue onto the stack.